import peewee
import cfg

db = peewee.SqliteDatabase(cfg.database())

class Client(peewee.Model):
    # 00:11:22:33:44:55
    mac = peewee.CharField()
    sn = peewee.CharField(default='')
    location = peewee.CharField(default='')
    rack = peewee.CharField(default='')

    class Meta:
        database = db

# class Tftp(peewee.Model):
#     # 00:11:22:33:44:55
#     mac = peewee.ForeignKeyField(Mac)
#     time = peewee.DateTimeField()

#     class Meta:
#         database = db

class Plan(peewee.Model):
    # mac = peewee.CharField()
    client = peewee.ForeignKeyField(Client)
    pxe = peewee.CharField()
    order = peewee.IntegerField()
    cycle = peewee.IntegerField()
    count = peewee.IntegerField(default=0)
    done = peewee.BooleanField(default=False)
    time = peewee.TimestampField()

    class Meta:
        database = db

class Log(peewee.Model):
    # mac = peewee.CharField()
    client = peewee.ForeignKeyField(Client)
    pxe = peewee.CharField()
    count = peewee.IntegerField()
    time = peewee.TimestampField()

    class Meta:
        database = db
